package com.yuyang.wifi.utils;

import android.content.Context;
import android.content.Intent;
import android.graphics.Color;
import android.os.Build;
import android.text.TextPaint;
import android.text.style.ClickableSpan;
import android.view.View;

import com.yuyang.wifi.activitys.web.WebViewSecretActivity;

import androidx.annotation.RequiresApi;

/**
 * created by mej
 * on 2020/9/24
 */
public class MyClickText extends ClickableSpan {
    private Context mContext;
    private int type;

    public MyClickText(Context context, int type) {
        this.mContext = context;
        this.type = type;
    }

    @RequiresApi(api = Build.VERSION_CODES.M)
    @Override
    public void updateDrawState(TextPaint ds) {
        super.updateDrawState(ds);
        //设置文本的颜色
        //ds.setColor(mContext.getResources().getColor(R.color.yellow_FEDA37));
        // ds.setColor(mContext.getColor(R.color.yellow_FEDA37));
        ds.setColor(Color.parseColor("#FEDA37"));
        //超链接形式的下划线，false 表示不显示下划线，true表示显示下划线
        ds.setUnderlineText(false);
    }

    @Override
    public void onClick(View widget) {
        if (type == 1) {
            Intent intent = new Intent(mContext, WebViewSecretActivity.class);
            intent.putExtra("url", "file:///android_asset/index2.html");
            intent.putExtra("title", "注册协议");
            mContext.startActivity(intent);
        } else if (type == 2) {
            Intent intent2 = new Intent(mContext, WebViewSecretActivity.class);
            intent2.putExtra("url", "file:///android_asset/index.html");
            intent2.putExtra("title", "隐私协议");
            mContext.startActivity(intent2);
        } else if (type == 3) {
            connectServiceDialog();
        }
    }

    private void connectServiceDialog() {

    }

}
